Skip to content

Fix handling of warnings on DML batches#1643

Open
ggilder wants to merge 3 commits intogithub:masterfrom
ggilder:fix-dml-batch-issue
Open

Fix handling of warnings on DML batches#1643
ggilder wants to merge 3 commits intogithub:masterfrom
ggilder:fix-dml-batch-issue

Conversation

@ggilder
Copy link
Contributor

@ggilder ggilder commented Mar 10, 2026

Related issue: #1636

Description

This is a follow-up to #1633 — this was actually an incomplete fix for the data loss issue described there, because any DML events that would cause data loss that happened in the middle of a batch could be masked by success of the final statement in the batch. This code change now runs SHOW WARNINGS after each statement in a batch so that we collect all warnings.

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.

Copilot AI review requested due to automatic review settings March 10, 2026 17:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves --panic-on-warnings safety during binlog replay by ensuring warnings emitted by any statement inside a batched DML multi-statement are detected (not just the last statement), addressing the masking/data-loss scenario from #1636 / follow-up to #1633.

Changes:

  • Add executeBatchWithWarningChecking() to interleave SHOW WARNINGS after each DML in a batch when PanicOnWarnings is enabled.
  • Update ApplyDMLEventQueries() to use the new warning-checking execution path only for PanicOnWarnings (keep existing fast path otherwise).
  • Add a new unit test and a new local integration test case to validate “warning in the middle of a batch” behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
localtests/panic-on-warnings-batch-middle/extra_args Adds localtest arguments enabling --panic-on-warnings with a unique index alter.
localtests/panic-on-warnings-batch-middle/expect_failure Asserts failure output contains warning-detection text.
localtests/panic-on-warnings-batch-middle/create.sql Sets up event-driven DML to reproduce a batched replay scenario.
go/logic/applier_test.go Adds unit test asserting mid-batch warning causes rollback of entire batch.
go/logic/applier.go Implements per-statement warning detection for batched DML execution under PanicOnWarnings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@ggilder
Copy link
Contributor Author

ggilder commented Mar 10, 2026

@meiji163 important correction to earlier data loss fix — lmk if you have questions

@ggilder
Copy link
Contributor Author

ggilder commented Mar 11, 2026

Working on fixing test flake issues here — will update when I have a passing build on my fork

@ggilder ggilder force-pushed the fix-dml-batch-issue branch 2 times, most recently from 2b7f7d9 to 47a5977 Compare March 12, 2026 00:44
@ggilder
Copy link
Contributor Author

ggilder commented Mar 12, 2026

I have a passing build now: ggilder#4
I rebased this on top of the improve-tests branch #1642 because I needed to use the same strategy to test DML handling in integration tests. So, that one should be merged first and then I can rebase back onto master.

@ggilder ggilder force-pushed the fix-dml-batch-issue branch from 47a5977 to 7245a90 Compare March 17, 2026 01:21
@ggilder
Copy link
Contributor Author

ggilder commented Mar 17, 2026

Tests passing on this branch again too. @meiji163 for review - the only differences between this PR and #1642 are the last 3 commits

@ggilder ggilder force-pushed the fix-dml-batch-issue branch from 7245a90 to 1e8f6ce Compare March 17, 2026 16:15
@ggilder
Copy link
Contributor Author

ggilder commented Mar 17, 2026

Rebased on latest master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants